﻿<!DOCTYPE html>
<html>
<!-- 行为安全观察与沟通结果统计表 -->
<!--By Songyf-->

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
        <script src="/static/js/common.js"></script>
        <script src="/static/js/main.js"></script>
    <style>
        .el-table.cell{
            white-space:pre-line;
        }
    </style>
</head>

<body>
    
<div id="app" v-cloak>   
    <el-form label-position="right" ref="form" :inline="true" :model="formInline" class="demo-form-inline"
             style="margin-bottom: 15px;">
        <el-row>
            <el-col class="head-tool">
                <div class="new_title fl"><strong><img src="/static/images/icon1.png" />行为安全观察与沟通结果统计表</strong></div>
                <span>
                    <btn :text="col.btnSelect" imgsrc="/static/images/search.png" linetype="3" @click="onSubmit"></btn>
                    <btn-export-list url="/api/JG_STOPObserveMain/ExportStatistic" :forminline="this.formInline" linetype="4"></btn-export-list>
                    
                </span>
            </el-col>
        </el-row>
      

        <el-row class="popupW100">

            <list-factorys v-model="formInline.model.createFactory" @change="factoryChange"></list-factorys>
            <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                <div class="elst-select-mini">
                    <el-form-item>
                        <el-input size="mini">
                            <template slot="prepend">
                                {{STOPInformationManagement.department+mark.m}}
                            </template>
                            <treeselect v-model="formInline.model.department"
                                        :options="department"
                                        :flat="true"
                                        :show-count="true"
                                        slot="suffix"
                                        style="line-height: 28px;"
                                        placeholder="请选择" />
                        </el-input>
                    </el-form-item>
                </div>
            </el-col>
            <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                <div class="elst-select-mini">
                    <el-form-item>
                        <el-input size="mini" style="z-index:100 !important;">
                            <template slot="prepend">
                                {{STOPInformationManagement.situation+mark.m}}
                            </template>
                            <treeselect v-model="formInline.model.situation"
                                        :options="situation"
                                        :flat="true"
                                        slot="suffix"
                                        :show-count="true"
                                        style="line-height: 28px;"
                                        placeholder="请选择" />
                        </el-input>
                    </el-form-item>
                </div>
            </el-col>


            <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                <div class="elst-select-mini">
                    <el-form-item>
                        <el-input size="mini">
                            <template slot="prepend">
                                {{STOPInformationManagement.shifts+mark.m}}
                            </template>
                            <el-select @visible-change="visibleChange" v-model="formInline.model.shifts" slot="suffix"
                                       placeholder="请选择">

                                <el-option v-for="item in shifts" :label="item.value" :value="item.key">
                                </el-option>
                            </el-select>
                        </el-input>
                    </el-form-item>
                </div>
            </el-col>
            <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                <div class="elst-select-mini">
                    <el-form-item>
                        <el-input v-model="formInline.model.observation"
                                  :placeholder="STOPInformationManagement.observation" size="mini">
                            <template slot="prepend">
                                {{STOPInformationManagement.observation+mark.m}}
                            </template>
                        </el-input>
                    </el-form-item>
                </div>
            </el-col>
            <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                <div class="elst-select-mini">
                    <el-form-item>
                        <el-input size="mini">
                            <template slot="prepend">
                                {{STOPInformationManagement.evaluation+mark.m}}
                            </template>
                            <el-select @visible-change="visibleChange" v-model="formInline.model.evaluationv" slot="suffix"
                                       :placeholder="STOPInformationManagement.evaluation">
                                <el-option label="请选择" value=""></el-option>
                                <el-option v-for="item in evaluation" :label="item.value" :value="item.key">
                                </el-option>
                            </el-select>
                        </el-input>
                    </el-form-item>
                </div>
            </el-col>
            <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                <div class="elst-select-mini">
                    <el-form-item>
                        <el-input size="mini">
                            <template slot="prepend">
                                {{STOPInformationManagement.observaDateStart+mark.m}}
                            </template>
                            <el-date-picker v-model="formInline.model.ObservationtimeStart" type="date" slot="suffix"
                                            size="mini" placeholder="选择日期">
                            </el-date-picker>

                        </el-input>
                    </el-form-item>
                </div>
            </el-col>

            <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                <div class="elst-select-mini">
                    <el-form-item>
                        <el-input size="mini">
                            <template slot="prepend">
                                {{STOPInformationManagement.observaDateEnd+mark.m}}
                            </template>
                            <el-date-picker v-model="formInline.model.ObservationtimeEnd" type="date" slot="suffix" size="mini" placeholder="选择日期">
                            </el-date-picker>

                        </el-input>
                    </el-form-item>
                </div>
            </el-col>


            <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                <div class="elst-select-mini">
                    <el-form-item>
                        <el-input size="mini">
                            <template slot="prepend">
                                {{STOPInformationManagement.observePeople+mark.m}}
                            </template>
                            <tree-department-staff-single-jgstop slot="suffix" v-model="formInline.model.observePeople" style="line-height:28px;"></tree-department-staff-single-jgstop>
                        </el-input>
                    </el-form-item>
                </div>
            </el-col>

        </el-row>
    </el-form>
        <el-table ref="table" stripe :data="ListItem.tableData" :row-key="getRowKeys" :height="ListItem.tableHeight" border
            @selection-change="handleSelectionChange" row-style="height:10px" style="width: 100%;" :summary-method="getSummaries" show-summary>
            <!--<el-table-column type="selection" style="padding-top: 0px;padding-bottom: 0px;" align="center" width="55" :reserve-selection="true">
            </el-table-column>-->
            <el-table-column type="index" :label="col.SequenceNumber" :index="indexMethod" width="50"></el-table-column>
            <el-table-column :label="BehaviorSafetyObservation.data" width="100" prop="observaDate">
                <!--<template slot-scope="scope">
                    <span>{{ formatDate(scope.row.observaDateText) }}</span>
                </template>-->
            </el-table-column>
            <el-table-column prop="shiftsText" :label="BehaviorSafetyObservation.Flights" width="50">
            </el-table-column>
            <el-table-column prop="observePeopleText" :label="BehaviorSafetyObservation.Observer" width="80">
            </el-table-column>
            <el-table-column :label="BehaviorSafetyObservation.unsafebehavior" min-width="150"
                             prop="correct" >
                <template slot-scope="scope">
                    <el-tooltip placement="top">
                        <div slot="content">
                            <div v-for="item in getLinesArray(scope.row.correct)"><span v-html="item"></span><br /></div>
                            
                        </div>
                        
                        <el-span>{{getCuttedText(scope.row.correct)}}</el-span>
                    </el-tooltip>
                </template>
                <!--<template slot-scope="scope" show-overflow-tooltip="true">

                    <p v-html="scope.row.correct"></p>
                </template>-->
            </el-table-column>
            <el-table-column prop="Classification" :label="BehaviorSafetyObservation.Classification" align="center">
                <el-table-column :label="BehaviorSafetyObservation.Personnelresponse"
                    width="150">

                    <template slot-scope="scope"><p v-html="scope.row.ryfy_remark"></p></template>
                </el-table-column>
                <el-table-column prop="rydwz_remark" :label="BehaviorSafetyObservation.Locationofpersonnel"
                                 width="220">
                    <template slot-scope="scope">
                        <p v-html="scope.row.rydwz_remark"></p>
                    </template>
                </el-table-column>
                <el-table-column prop="grfhzb_remark" :label="BehaviorSafetyObservation.protectiveequipment"
                                 width="150" show-overflow-tooltip="true">
                    <template slot-scope="scope">
                        <p v-html="scope.row.grfhzb_remark"></p>
                    </template>
                </el-table-column>
                <el-table-column prop="gjjsb_remark" :label="BehaviorSafetyObservation.Toolsandequipment"
                                 width="200" show-overflow-tooltip="true">
                    <template slot-scope="scope">
                        <p v-html="scope.row.gjjsb_remark"></p>
                    </template>
                </el-table-column>
                <el-table-column prop="cx_remark" :label="BehaviorSafetyObservation.program" width="150">
                    <template slot-scope="scope">
                        <p v-html="scope.row.cx_remark"></p>
                    </template>
                </el-table-column>
                <el-table-column prop="zxbz_remark" :label="BehaviorSafetyObservation.StandardofOrder" width="150">
                    <template slot-scope="scope">
                        <p v-html="scope.row.zxbz_remark"></p>
                    </template>
                </el-table-column>
            </el-table-column>
        </el-table>
        <!--<el-row type="flex" justify="end" style="margin-top:10px;">
            <el-pagination ref="page" @size-change="handleSizeChange" @current-change="handleCurrentChange"
                :current-page="ListItem.currentPage" :page-sizes="ListItem.pagesizes" :page-size="ListItem.pagesize"
                :layout="ListItem.layout" :total="ListItem.total">
            </el-pagination>
        </el-row>-->
    </div>
    <script type="text/javascript">
         Vue.component('tree-department-staff-single-jgstop', {
            props: ['value', 'multiple'],
            data: function () {
                return {
                    options: [],
                    valueConsistsOf: "LEAF_PRIORITY"
                }
            },
            methods: {
                input: function (v, instanceId) {
                    console.log(v);
                    this.$emit('input', v);
                },
                getData: function () {
                    var app = this;
                    myAjax("Get", null, "/api/JG_STOPObserveMain/GetTreeDepartmentStaff", null, function (response) {
                        var ajaxModel = response.data;
                        app.options = PersonMenuHelper(ajaxModel, guidEmpty);
                    }, false);
                }
            },
            mounted: function () {
                this.getData();
            },
            template: ' <treeselect :multiple="multiple"     :disable-branch-nodes="true"   :value-consists-of="valueConsistsOf"  :options="options"    v-model="value" @input="input"  />'

        })
        var app = new Vue({
            el: '#app',
            data: {
                
                //表单内容
                ListItem: ListItem,
                value1: '',
                situation: [],
                    department: [],
                    evaluation: [],
                    shifts:[],
                formInline: {
                    model: {

                        createFactory:null,
                            observePeople: null,    //观察人
                            observation: "",        //观察时间(h)
                            shifts: null,           //班次
                            situation: null,        //区域
                            department: null,       //部门
                            observaDate: "",        //观察日期
                            evaluationv: null,      //是否所有皆安全 
                            ObservationtimeStart: null, //开始日期
                            ObservationtimeEnd: null,   //结束日期
                    },
                    offset: 0,
                    limit: 10
                },
                summary: {
                    ryfy: '',
                    grfhzb: '',
                    rydwz: '',
                    gjjsb: '',
                    cx: '',
                    zxbz:'',
                }
                    
            },
            mounted: function () {
                //this.ListItem.pagesize = 999;
                this.getDepartmentData();               //绑定部门
                this.shifts = getDicData('n51');        //绑定班次
                this.GetAreaList();                     //绑定区域
                this.evaluation = getDicData('是与否'); //绑定是否全部安全
                //console.log(getDicDataArray(["01", "02", "03", "04"]))
                //初始化数据
                this.GetPageData(1);
                //列表高度自适应
                tablehigh(this);
            },
            methods: {
                factoryChange: function () {
                    this.getDepartmentData();
                    this.GetAreaList();
                },
                getDepartmentData: function () {
                    var mythis = this;
                    myAjax("post", this, '/api/SysDepartment/GetList', { model: { Name: '', Code: '', CreateFactory: mythis.formInline.model.createFactory }, offset: 0, limit: 999 }, function (response) {
                        mythis.department = menuHelperX(response.data.pageData, guidEmpty)
                    }, false);
                },
                //获得区域列表
                GetAreaList: function () {
                    var mythis = this;
                    myAjax("post", this, '/api/SysArea/GetList', { model: { Name: '', Code: '', SubFactory: mythis.formInline.model.createFactory }, offset: 0, limit: 999 }
                        , function (response) {
                            
                            mythis.situation = menuHelper(response.data.pageData, null);
                            
                        },
                        false);
                },
                getCuttedText(text) {
                    if (text.length > 8) {
                        return text.substr(0, 8) + '...';
                    }
                    else {
                        return text;
                    }


                    
                },
                getSummaries(param) {
                    var mythis = this;
                    const { columns, data } = param;
                    const sums = [];
                    columns.forEach((column, index) => {
                      if (index === 0) {
                        sums[index] = '合计';
                        return;
                        }
                        if (index == 5) {
                            sums[index] = mythis.summary.ryfy;
                        return;
                        }
                        if (index == 6) {
                            sums[index] = mythis.summary.grfhzb;
                        return;
                        }
                        if (index == 7) {
                            sums[index] = mythis.summary.rydwz;
                        return;
                        }
                        if (index == 8) {
                            sums[index] = mythis.summary.gjjsb;
                        return;
                        }
                        if (index == 9) {
                            sums[index] = mythis.summary.cx;
                        return;
                        }
                        if (index == 10) {
                            sums[index] = mythis.summary.zxbz;
                        return;
                        }
                      
                    });

                    return sums;
                  },
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                indexMethod: function (index) {
                    return (this.ListItem.currentPage - 1) * this.ListItem.pagesize + index + 1;
                },
                //列表选择触发
                handleSelectionChange: function (val) { handleSelectionChange(this, val); },
                //获取分页数据
                GetPageData: function (currentIndex) { 
                    
                    var mythis = this;
                    GetPageData(this, currentIndex, '/api/JG_STOPObserveMain/GetStatisticsList')
                    var startDate = mythis.formInline.model.ObservationtimeStart;
                    var endDate = mythis.formInline.model.ObservationtimeEnd;
                    
                    myAjax("post", mythis,'/api/JG_STOPObserveMain/GetStatisticsSummary', mythis.formInline, function (response) {
                       mythis.summary = response.data;

                    });
                    //myAjax("get", mythis, '/api/JG_STOPObserveMain/GetStatisticsSummary?startDate=' + startDate + '&endDate=' + endDate, null, function (response) {
                    //    mythis.summary = response.data;
                            
                    //    }, false);
                },
                //查询方法
                onSubmit: function () { onSubmit(this); },
                //pagesize改变 触发方法
                handleSizeChange: function (val) { handleSizeChange(this, val); },
                //跳页触发方法
                handleCurrentChange: function (val) { handleCurrentChange(this, val); },
                //获取下拉菜单数据
                getDropDown: function () {
                },
                getLinesArray: function (content) {
                    var lines = content.split('\n');
                    
                    return lines;
                }



            }
        });

        //下拉树数据格式化
        function menuHelperX(list, pid) {
            var result = [];
            if (list.length <= 0)
                return list;
            list.forEach(function (v, i) {
                var temp = {};
                for (var key in v) {
                    temp[key] = v[key];
                }
                temp.label = v.name;
                temp.parentId = temp.parentId ? temp.parentId : guidEmpty;
                var obj;
                if (temp.parentId == pid) {
                    obj = temp;
                    var nextObj = menuHelperX(list, temp.id);
                    if (nextObj.length > 0) {
                        obj.children = nextObj;
                    }
                }
                if (obj)
                    result.push(obj)
            })
            return result;
        }

        //下拉树数据格式化
        function menuHelper(list, pid) {

            var result = [];
            if (list.length <= 0)
                return list;
            list.forEach(function (v, i) {
                var temp = {};
                for (var key in v) {
                    temp[key] = v[key];
                }
                temp.label = v.name;
                //temp.parentId = temp.parentId ? temp.parentId : guidEmpty;
                var obj;
                if (temp.parentId == pid) {
                    obj = temp;
                    var nextObj = menuHelper(list, temp.id);
                    if (nextObj.length > 0) {
                        obj.children = nextObj;
                    }
                }
                if (obj)
                    result.push(obj)
            })
            return result;
        }
    </script>
</body>

</html>